//
// Created by Jisam on 2024/7/13.
//
#include <bits/stdc++.h>
#define PSI pair<string,int>
#define PII pair<int,int>
#define x first
#define y second
#define i64 long long
using namespace std;
const int N = 1e5 + 5;
int ans;
void solve() {
    int n;
    cin >> n;
    vector<string> a(n);
    for(int i = 0 ; i < n ; i ++){
        cin>> a[i];
    }
    sort(a.begin(),a.end(),[&](string s1 ,string s2){
        if(s1.length() == s2. length())
            return s1 > s2;
        else {
            int f = 0;
            int maxlen = max(s1.length() , s2.length());
            for(int i = 0 ;i < maxlen ; i ++){
                if(s1[(i + s1.length()) % s1.length()] == s2[(i + s2.length()) % s2.length()]){
                    continue;
                }else if(s1[(i + s1.length()) % s1.length()] > s2[(i + s2.length()) % s2.length()]){
                    return true;
                }else{
                    return false;
                }
            }
            return true;
        }
    });
    for(int i = 0 ; i < n ; i ++){
        cout << a[i];
    }
    cout << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
//    int T;cin >> T;while(T --)
    solve();
    return 0;
}